<template>
  <div class="add-manager-dialog">
    <el-dialog
      title="新增管理员"
      :visible.sync="visible"
      width="500px"
      center
      :show-close="false"
      :close-on-click-modal="false"
    >
      <div class="content">
        <div class="line flex-left">
          <label class="title">账号</label>
          <el-input v-model="param.username" placeholder="请输入管理员账号" class="line"></el-input>
        </div>
        <div class="line flex-left">
          <label class="title">密码</label>
          <el-input v-model="param.password" placeholder="请输入管理员密码" class="line"></el-input>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="param={username:'',password:''};$emit('cancel')">取 消</el-button>
        <el-button
          size="small"
          type="primary"
          @click="submit"
          :disabled="onSubmit"
          :loading="onSubmit"
        >确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { addManager } from "./system.service.js";
export default {
  props: ["platform_id", "visible"],
  data() {
    return {
      param: {
        username: "",
        password: ""
      },
      onSubmit: false
    };
  },
  methods: {
    async submit() {
      let platform_id = this.platform_id;
      const res = await addManager({ ...this.param, ...{ platform_id } });
      if (res.code === 0) {
        this.$notify.success({
          title: "提示",
          message: "添加成功"
        });
        this.parap = {
          username: "",
          password: ""
        };
        this.$emit("success");
      }
    }
  }
};
</script>

<style lang="scss">
.add-manager-dialog {
  .el-dialog__header {
    border-bottom: 1px solid #e9e9e9;
    padding: 15px;
    font-weight: 600;
  }
  .content {
    .line {
      line-height: 60px;
      .title {
        width: 5em;
        text-align: right;
        margin-right: 20px;
        flex-shrink: 0;
      }
      span {
        margin-left: 20px;
      }
      .ico {
        margin: 0 5px;
      }
    }
    .line {
      width: 400px;
    }
  }
}
</style>